﻿using System;

using E.BLL;
using E.Model;
using E.Web.UI.Page;

using X.Common;

namespace E.Web.Teacher.info
{
    public partial class UpdateInfo : TeacherBasePage
    {
        public TeacherModel model;

        protected override void ShowPage()
        {
            TeacherBLL bll = new TeacherBLL();
            model = bll.GetTeacherInfo(teacherid);

            if (ispost)
            {
                string name = XRequest.GetString("NameTxt");
                string email = XRequest.GetString("EmailTxt");
                bool gender = XRequest.GetInt("GenderRg", -1) == 1 ? true : false;

                if (name.Equals(""))
                {
                    ExecuteJS("alert('信息填写错误');");
                }
                else
                {
                    model = new TeacherModel();
                    model.ID = teacherid;
                    model.Name = name;
                    model.Email = email;
                    model.Gender = gender;
                    model.Authority = (E.Enum.EnumTeacherAuthority)XRequest.GetInt("av", -1);

                    int rst = bll.UpdateTeacherInfo(model);
                    if (rst > 0)
                    {
                        ExecuteJS("alert('更新成功');");
                    }
                    else
                    {
                        ExecuteJS("alert('信息填写错误');");
                    }
                }
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {

        }
    }
}
